using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy_SkeletonAnimationTriggers : MonoBehaviour
{
  private Enemy_Skeleton enemy => GetComponentInParent<Enemy_Skeleton>();

  private void AnimationTrigger()
  {
    enemy.AnimationFinishTrigger();
  }

  private void AttackTrigger()
  {
    //获取一个圆形区域内所有碰撞器的列表
    Collider2D[] colliders = Physics2D.OverlapCircleAll(enemy.attackCheck.position, enemy.attackCheckRadius);

    foreach (var hit in colliders)
    {
      if (hit.GetComponent<Player>() != null)
      {
        PlayerStats _target = hit.GetComponent<PlayerStats>();
        enemy.stats.DoDamage(_target);
      }
    }
  }

  private void OpenCounterAttackWindow() => enemy.OpenCounterAttackWindow();

  private void CloseCounterAttackWindow() => enemy.CloseCounterAttackWindow();

}
